INSERT INTO {{ tableName }} (
  id,
  event_timestamp,
  created_timestamp,
  {{ join(featureNames, ', ') }}
)
VALUES (
  ?,
  ?,
  now(),
  {% for featureName in featureNames -%}
      ?{% if not(loop.last) %}, {% endif %}
  {%- endfor %}
)
ON CONFLICT (id, event_timestamp)
DO UPDATE
  SET created_timestamp = now(),
    {%- for featureName in featureNames %}
      {{ featureName }} = COALESCE(EXCLUDED.{{ featureName }}, {{ tableName }}.{{ featureName }})
      {%- if not(loop.last) %},{% endif -%}
    {% endfor %}
